<template>
	<view>
		<CustomNavbar :title="pageTitle">
			<view slot="left">
		 	<image class="back-btn" src="@/static/iocn57.png" mode="aspectFit" @click="onBack" />
			</view>
			<view slot="right">
				<uni-icons type="plus-filled" size="30" @click="toincrease"></uni-icons>
			</view>
		</CustomNavbar>
		<view class="navto">
			<text @click="toyonggong()">点击前往用工管理~</text>
		</view>
		<!-- 页面内容 -->
		<view class="body">
			<view class="container" v-for="(item,index) in list">
				<view class="fr">
					<view class="text_a" @click="toxiangqing(item)">{{item.empName}}</view>
					<view class="text_b" @click="toxiangqing(item)">手机号: {{item.mobile}}</view>
					<view class="text_b" @click="toxiangqing(item)">身份证号: {{item.identityNumber}}</view>
					<view class="text_c" @click="shanchushow = true">删除</view>
					<view class="text_c" @click="torevise(item)">修改</view>
				</view>
				<view>
					<u-modal :show="shanchushow" :showCancelButton="true" @confirm="confirms(item)" @cancel="cancel"
			 		title="确定删除" :content="content"></u-modal>
				</view>
		 </view>
		</view>
		
	</view>
</template>

<script>
	import {
		GetEmployees,
		EmployeeDelete
	} from '@/public/Api/update.js'
	import {
		setValue,
		getValue
	} from '@/public/storeage/index.js'
	import Tabbar from '@/pages/navigation/navigation.vue';
	import CustomNavbar from '@/components/CustomNavbar.vue'
	export default {
		components: {
			CustomNavbar
		},
		data() {
			return {
				skipCount: 0,
				maxResultCount: 10,
				pageIndex: 1,
				pageTitle: '员工管理',
				list: [],
				shanchushow: false,
			}
		},
		onShow() {
			this.GetEmployees()
		},
		//监听页面触底函数
		onReachBottom() {
			this.pageIndex += 1
		},
		methods: {
			onBack() {
				uni.reLaunch({
					url:'/pages/PersonalCenter/index'
				})
			},
			toincrease() {
				uni.navigateTo({
					url: '/pages/PersonalCenter/newlyIncreased'
				})
			},
			toyonggong(){
				uni.navigateToMiniProgram({
					appId:'wx19b7ecb2cf2b625d',
					path:"pages/index/bossindex",
					envVersion:'release',
					success(res) {
						if(res.errMsg=="navigateToMiniProgram:ok"){
							uni.showToast({
							  title: "跳转成功",
							  icon: "none",
							});
						}
					},
					fail(err) {
						uni.showToast({
						  title: "跳转失败",
						  icon: "none",
						});
					}
				})
			},
			torevise(item) {
				var id = item.id
				uni.navigateTo({
					url: '/pages/PersonalCenter/revise?id=' + id + '&empName=' + item.empName + '&mobile=' + item
						.mobile + '&identityNumber=' + item.identityNumber + '&bankName=' + item.bankName +
						'&bankAccount=' + item.bankAccount + '&sex=' + item.sex + '&idNumberPic=' + item
						.idNumberPic + '&idNumberPic2=' + item.idNumberPic2
				})
			},
			toxiangqing(item) {
				uni.navigateTo({
					url: '/pages/PersonalCenter/detailedInformation?empName=' + item.empName + '&mobile=' + item
						.mobile + '&identityNumber=' + item.identityNumber + '&bankName=' + item.bankName +
						'&bankAccount=' + item.bankAccount
				})
			},
			async GetEmployees() {
				var skipCount = (this.pageIndex - 1) * this.maxResultCount
				var maxResultCount = this.maxResultCount
				var userId = getValue('id')
				try {
					const {
						data: res
					} = await GetEmployees({
						skipCount,
						maxResultCount,
						userId
					})
					this.list = res.result.items
				} catch (e) {}

			},
			// 确认
			async confirms(item) {
				this.shanchushow = false;
				try {
					const {
						data: res
					} = await EmployeeDelete([item.id]);
					console.log(res);
					this.GetEmployees();
				} catch (e) {}
			},
			// 取消
			cancel() {
				this.shanchushow = false;
			},

		}
	}
</script>

<style lang="scss">
	.back-btn {
		width: 24px;
		height: 24px;
	}

	.navbar-btn {
		font-size: 14px;
	}
    .navto{
		line-height: 50upx;
		text-align: center;
		color: #71A0FA;
		margin-top: 20upx;
	}
	.body {
		margin-top: 20upx;
	}

	.container {
		border-radius: 17upx;
		background: #FFFFFF;
		box-shadow: 1.75upx 1.75upx 7.01upx 0px #e5e5e5, 1.75upx 1.75upx 7.01upx 0px #e5e5e5;
		padding: 10upx 10upx;
		margin-top: 20upx;
		display: flex;
		align-items: center;
		justify-content: space-between;

		.fr {
			width: 100%;
			padding-left: 20upx;

			.text_a {
				font-size: 32upx;
				color: #000;
				font-weight: bold;
				margin-top: 10upx;
			}

			.text_d {
				font-size: 30upx;
				color: #383838;
				margin-top: 10upx;
			}

			.text_b {
				text {
					font-size: 30upx;
					color: #383838;
					margin-top: 15upx;
				}
			}

			.text_c {
				width: 133upx;
				height: 51upx;
				background-color: #ef4d3d;
				font-size: 24upx;
				color: #fff;
				text-align: center;
				line-height: 51upx;
				border-radius: 10upx;
				margin-top: 30upx;
				float: right;
				margin-right: 10upx;
			}
		}
	}
</style>
